package com.aop.logging;

/*
 * 实现方法：1.通过动态代理来实现。
 */
public class ArithmeticCalculatorImplLogging implements ArithmeticCalculator {

	@Override
	public int add(int i, int j) {
		//除了逻辑运算，还需要提供打印服务。缺点:1.会让代码混乱，不好维护 2.如果日志需要维护则比较麻烦。
		System.out.println("The method add begins with[" + i +"," + j+"]");
		int result=i+j;
		System.out.println("The method add ends with "+result);
		return result;
	}

	@Override
	public int sub(int i, int j) {
		System.out.println("The method sub begins with[" + i +"," + j+"]");
		int result=i-j;
		System.out.println("The method sub ends with "+result);
		return result;
	}

	@Override
	public int mul(int i, int j) {
		System.out.println("The method mul begins with[" + i +"," + j+"]");
		int result=i*j;
		System.out.println("The method mul ends with "+result);
		return result;
	}

	@Override
	public int div(int i, int j) {
		System.out.println("The method div begins with[" + i +"," + j+"]");
		int result=i/j;
		System.out.println("The method div ends with "+result);
		return result;
	}

}
